#########################################
# K_Engine
#
# @Author : Kai.Leung 
# @Data   : 2016-3-31
#
#########################################

TARGET=K_Engine
CPP=g++
CXXFLAGS=-g -Wall -pthread -std=c++11 -ldl
BASE_PATH=_Base
MODULE_PATH=_Module
OBJ_TEMP_PATH=obj
LIB_TEMP_PATH=lib


.PHONY : default all libkjson clean test

default: all libkjson
	$(CPP) $(CXXFLAGS) $(OBJ_TEMP_PATH)/*.o ./lib/libKJson.a -o $(TARGET)
      
libkjson :
	cd ../../K_Json && make
	mv ../../K_Json/lib/libKJson.a ./lib/
	  
all :
ifneq ($(OBJ_TEMP_PATH), $(wildcard $(OBJ_TEMP_PATH)))
	mkdir $(OBJ_TEMP_PATH)
endif
ifneq ($(LIB_TEMP_PATH), $(wildcard $(LIB_TEMP_PATH)))
	mkdir $(LIB_TEMP_PATH)
endif
ifneq (log, $(wildcard log))
	mkdir log
endif
	cd $(BASE_PATH) && make
	mv $(BASE_PATH)/*.o $(OBJ_TEMP_PATH)/ 
	cd $(MODULE_PATH) && make
	mv $(MODULE_PATH)/*.o $(OBJ_TEMP_PATH)/

work : 
	cd _Work && make

test : 
	cd _Work && make $@

clean:
	rm -rf $(LIB_TEMP_PATH)
	rm -rf $(OBJ_TEMP_PATH)
	rm -rf log
	rm -rf $(TARGET)